package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.OrderDTO;
import com.itheima.pojo.OrderVO;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController("mobileOrderController")
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;
    @GetMapping("findById")
    Result findById(Integer id){
        log.info("根据id查询预约信息：{}", id);
        OrderVO orderVO=orderService.findById(id);
        return new Result(true,"查询预约信息成功",orderVO);
    }
    @PostMapping("/submitOrder")
    public Result addOrder(@RequestBody OrderDTO orderDTO){
        log.info("体检预约：{}", orderDTO);
        Integer id = orderService.addOrder(orderDTO);
        return new Result(true, MessageConstant.ORDER_SUCCESS, id);
    }

}
